import time

import requests


def trans_uid_to_containerid(uid):
    """
    将微博用户的userid 转换成container id
    :param uid:
    :return:
    """
    cid_prefix = '230413'
    containerid = cid_prefix + str(uid)
    return containerid


def get_followed_list(my_cid):
    headers = {
        "user-agent": 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Mobile Safari/537.36',
        "cookie": "WEIBOCN_FROM=1110005030; SUB=_2A25N8vWNDeRhGeBN71cV8C7Oyj6IHXVvHJvFrDV6PUJbkdAKLVSmkW1NRGRs1AL4P_iLk8TuWjjlBh-9wjpSq8bP; _T_WM=91827081133; MLOGIN=1; M_WEIBOCN_PARAMS=luicode%3D10000011%26lfid%3D231093_-_selffollowed%26fid%3D231093_-_lastmblog%26uicode%3D10000011; XSRF-TOKEN=e75f0a",
        "upgrade-insecure-requests": '1'

    }

    content = requests.get('https://m.weibo.cn/api/container/getIndex?containerid=231093_-_selffollowed',
                           headers=headers)


def trans_format(time_string, from_format='%a %b %d %H:%M:%S +0800 %Y', to_format='%Y-%m-%d %H:%M:%S'):

    time_struct = time.strptime(time_string, from_format)
    times = time.strftime(to_format, time_struct)
    return times


if __name__ == '__main__':
    cst_time = "Thu May 09 19:42:29 +0800 2019"
    format_time = trans_format(cst_time, '%a %b %d %H:%M:%S +0800 %Y', '%Y-%m-%d %H:%M:%S')
    print(format_time)
